<?php
/*
本页是验证邮箱页
*/
header('content-type:text/html;charset=utf-8');
include '../include/init.php';


session_start();

if(!isset($_SESSION['valmailcode'])||!isset($_GET['code']))
{
	echo 'This page is over deadline';
	exit;
}
if(!$_SESSION['valmailcode']==$_GET['code'])
{
	echo 'This page is over deadline';
	exit;
}

$ex=explode(',',$_SESSION['valmailcode']);
$time=$ex[0];

$timeout=time()-$time;
if($timeout>=1800)
{
	session_unset();
	session_destroy();
	echo 'timeout over，please rebuild';
	exit;
}



//验证码正确，修改入库

$usr=new userModel();

if($usr->modify($_SESSION['usr'],'email_validate','1'))
{
	echo '<center><h1>邮箱激活成功，您可以使用邮箱账号或个人账号登录肥扣扣，感谢您的注册支持！</h1></center>';
}
else
{
	echo '<center><h1 style="color:red;">抱歉验证失败，请您重新验证邮箱</h1></center>';
}
//销毁session以防止多次提交
session_unset();
session_destroy();